Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Variable-length code</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Variable-length_code"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.math.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Variable-length_code rootpage-Variable-length_code skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Variable-length code</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">This article is about the transmission of data across noisy channels. For the storage of text in computers, see <a href="Variable-width_encoding" title="Variable-width encoding">variable-width encoding</a>.</div><style data-mw-deduplicate="TemplateStyles:r1251242444">
/* start https://en.wikipedia.org/ */


.mw-parser-output .ambox{border:1px solid #a2a9b1;border-left:10px solid #36c;background-color:#fbfbfb;box-sizing:border-box}.mw-parser-output .ambox+link+.ambox,.mw-parser-output .ambox+link+style+.ambox,.mw-parser-output .ambox+link+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+style+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+link+.ambox{margin-top:-1px}html body.mediawiki .mw-parser-output .ambox.mbox-small-left{margin:4px 1em 4px 0;overflow:hidden;width:238px;border-collapse:collapse;font-size:88%;line-height:1.25em}.mw-parser-output .ambox-speedy{border-left:10px solid #b32424;background-color:#fee7e6}.mw-parser-output .ambox-delete{border-left:10px solid #b32424}.mw-parser-output .ambox-content{border-left:10px solid #f28500}.mw-parser-output .ambox-style{border-left:10px solid #fc3}.mw-parser-output .ambox-move{border-left:10px solid #9932cc}.mw-parser-output .ambox-protection{border-left:10px solid #a2a9b1}.mw-parser-output .ambox .mbox-text{border:none;padding:0.25em 0.5em;width:100%}.mw-parser-output .ambox .mbox-image{border:none;padding:2px 0 2px 0.5em;text-align:center}.mw-parser-output .ambox .mbox-imageright{border:none;padding:2px 0.5em 2px 0;text-align:center}.mw-parser-output .ambox .mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output .ambox .mbox-image-div{width:52px}@media(min-width:720px){.mw-parser-output .ambox{margin:0 10%}}@media print{body.ns-0 .mw-parser-output .ambox{display:none!important}}


/* end https://en.wikipedia.org/ */
</style>
<p>
In <a href="Coding_theory" title="Coding theory">coding theory</a>, a <b>variable-length code</b> is a <a href="Code" title="Code">code</a> which maps source symbols to a <i>variable</i> number of <a href="Bit" title="Bit">bits</a>. The equivalent concept in <a href="Computer_science" title="Computer science">computer science</a> is <i><a href="Bit_string" class="mw-redirect" title="Bit string">bit string</a></i>.
</p><p>Variable-length codes can allow sources to be <a href="Data_compression" title="Data compression">compressed</a> and decompressed with <i>zero</i> error (<a href="Lossless_data_compression" class="mw-redirect" title="Lossless data compression">lossless data compression</a>) and still be read back symbol by symbol. With the right coding strategy, an <a href="Independent_and_identically-distributed_random_variables" class="mw-redirect" title="Independent and identically-distributed random variables">independent and identically-distributed source</a> may be compressed almost arbitrarily close to its <a href="Information_entropy" class="mw-redirect" title="Information entropy">entropy</a>. This is in contrast to fixed-length coding methods, for which data compression is only possible for large blocks of data, and any compression beyond the logarithm of the total number of possibilities comes with a finite (though perhaps arbitrarily small) probability of failure.
</p><p>Some examples of well-known variable-length coding strategies are <a href="Huffman_coding" title="Huffman coding">Huffman coding</a>, <a href="Lempel%E2%80%93Ziv_coding" class="mw-redirect" title="Lempel–Ziv coding">Lempel–Ziv coding</a>, <a href="Arithmetic_coding" title="Arithmetic coding">arithmetic coding</a>, and <a href="Context-adaptive_variable-length_coding" title="Context-adaptive variable-length coding">context-adaptive variable-length coding</a>.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Codes_and_their_extensions">Codes and their extensions</h2></div>
<p>The extension of a code is the mapping of finite length source sequences to finite length bit strings, that is obtained by concatenating for each symbol of the source sequence the corresponding codeword produced by the original code.
</p><p>Using terms from <a href="Formal_language_theory" class="mw-redirect" title="Formal language theory">formal language theory</a>, the precise mathematical definition is as follows: Let <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle S}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>S</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle S}</annotation>
</semantics>
</math></span><img src="./4611d85173cd3b508e67077d4a1252c9c05abca2.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.499ex; height:2.176ex;" alt="{\displaystyle S}" loading="lazy"></span> and <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle T}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>T</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle T}</annotation>
</semantics>
</math></span><img src="./ec7200acd984a1d3a3d7dc455e262fbe54f7f6e0.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.636ex; height:2.176ex;" alt="{\displaystyle T}" loading="lazy"></span> be two finite sets, called the source and target <a href="Alphabet_(computer_science)" class="mw-redirect" title="Alphabet (computer science)">alphabets</a>, respectively. A <b>code</b> <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle C:S\to T^{*}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>C</mi>
<mo>:</mo>
<mi>S</mi>
<mo stretchy="false">→<!-- → --></mo>
<msup>
<mi>T</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>∗<!-- ∗ --></mo>
</mrow>
</msup>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle C:S\to T^{*}}</annotation>
</semantics>
</math></span><img src="./1b7b8613b37c669052d75c6231bf67771b83063a.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:11.591ex; height:2.343ex;" alt="{\displaystyle C:S\to T^{*}}" loading="lazy"></span> is a total function<sup id="cite_ref-:0_1-0" class="reference"><a href="#cite_note-:0-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> mapping each symbol from <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle S}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>S</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle S}</annotation>
</semantics>
</math></span><img src="./4611d85173cd3b508e67077d4a1252c9c05abca2.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.499ex; height:2.176ex;" alt="{\displaystyle S}" loading="lazy"></span> to a <a href="Word_(data_type)" class="mw-redirect" title="Word (data type)">sequence of symbols</a> over <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle T}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>T</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle T}</annotation>
</semantics>
</math></span><img src="./ec7200acd984a1d3a3d7dc455e262fbe54f7f6e0.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.636ex; height:2.176ex;" alt="{\displaystyle T}" loading="lazy"></span>, and the extension of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle C}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>C</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle C}</annotation>
</semantics>
</math></span><img src="./4fc55753007cd3c18576f7933f6f089196732029.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.766ex; height:2.176ex;" alt="{\displaystyle C}" loading="lazy"></span> to a <a href="Homomorphism#Formal_language_theory" title="Homomorphism">homomorphism</a> of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle S^{*}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msup>
<mi>S</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>∗<!-- ∗ --></mo>
</mrow>
</msup>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle S^{*}}</annotation>
</semantics>
</math></span><img src="./b059338b0f6bc81c4edf97c51ce987e98f4bf23e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.576ex; height:2.343ex;" alt="{\displaystyle S^{*}}" loading="lazy"></span> into <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle T^{*}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msup>
<mi>T</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>∗<!-- ∗ --></mo>
</mrow>
</msup>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle T^{*}}</annotation>
</semantics>
</math></span><img src="./5426ed7abdea7d2ff995ad0e01bc4ca62a273855.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.774ex; height:2.343ex;" alt="{\displaystyle T^{*}}" loading="lazy"></span>, which naturally maps each sequence of source symbols to a sequence of target symbols, is referred to as its <b>extension</b>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Classes_of_variable-length_codes">Classes of variable-length codes</h2></div>
<p>Variable-length codes can be strictly nested in order of decreasing generality as non-singular codes, uniquely decodable codes, and prefix codes. Prefix codes are always uniquely decodable, and these in turn are always non-singular:
</p>
<div class="mw-heading mw-heading3"><h3 id="Non-singular_codes">Non-singular codes</h3></div>
<p>A code is <b>non-singular</b> if each source symbol is mapped to a different non-empty bit string; that is, the mapping from source symbols to bit strings is <a href="Injective" class="mw-redirect" title="Injective">injective</a>.
</p>
<ul><li>For example, the mapping <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{1}=\{\,a\mapsto 0,b\mapsto 0,c\mapsto 1\,\}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>M</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>=</mo>
<mo fence="false" stretchy="false">{</mo>
<mspace width="thinmathspace"></mspace>
<mi>a</mi>
<mo stretchy="false">↦<!-- ↦ --></mo>
<mn>0</mn>
<mo>,</mo>
<mi>b</mi>
<mo stretchy="false">↦<!-- ↦ --></mo>
<mn>0</mn>
<mo>,</mo>
<mi>c</mi>
<mo stretchy="false">↦<!-- ↦ --></mo>
<mn>1</mn>
<mspace width="thinmathspace"></mspace>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle M_{1}=\{\,a\mapsto 0,b\mapsto 0,c\mapsto 1\,\}}</annotation>
</semantics>
</math></span><img src="./294024f145e41457d784606e9b5742a6d7ca7ffe.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:29.138ex; height:2.843ex;" alt="{\displaystyle M_{1}=\{\,a\mapsto 0,b\mapsto 0,c\mapsto 1\,\}}" loading="lazy"></span> is <i>not</i> non-singular because both "a" and "b" map to the same bit string "0"; any extension of this mapping will generate a lossy (non-lossless) coding. Such singular coding may still be useful when some loss of information is acceptable (for example, when such code is used in audio or video compression, where a lossy coding becomes equivalent to source <a href="Quantization_(signal_processing)" title="Quantization (signal processing)">quantization</a>).</li>
<li>However, the mapping <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{2}=\{\,a\mapsto 1,b\mapsto 011,c\mapsto 01110,d\mapsto 1110,e\mapsto 10011,f\mapsto 0\}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>M</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<mo>=</mo>
<mo fence="false" stretchy="false">{</mo>
<mspace width="thinmathspace"></mspace>
<mi>a</mi>
<mo stretchy="false">↦<!-- ↦ --></mo>
<mn>1</mn>
<mo>,</mo>
<mi>b</mi>
<mo stretchy="false">↦<!-- ↦ --></mo>
<mn>011</mn>
<mo>,</mo>
<mi>c</mi>
<mo stretchy="false">↦<!-- ↦ --></mo>
<mn>01110</mn>
<mo>,</mo>
<mi>d</mi>
<mo stretchy="false">↦<!-- ↦ --></mo>
<mn>1110</mn>
<mo>,</mo>
<mi>e</mi>
<mo stretchy="false">↦<!-- ↦ --></mo>
<mn>10011</mn>
<mo>,</mo>
<mi>f</mi>
<mo stretchy="false">↦<!-- ↦ --></mo>
<mn>0</mn>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle M_{2}=\{\,a\mapsto 1,b\mapsto 011,c\mapsto 01110,d\mapsto 1110,e\mapsto 10011,f\mapsto 0\}}</annotation>
</semantics>
</math></span><img src="./e7077bf9dbc7c975f4d5f510567a34ca5ff0e1d7.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:64.872ex; height:2.843ex;" alt="{\displaystyle M_{2}=\{\,a\mapsto 1,b\mapsto 011,c\mapsto 01110,d\mapsto 1110,e\mapsto 10011,f\mapsto 0\}}" loading="lazy"></span> <i>is</i> non-singular; its extension will generate a lossless coding, which will be useful for general data transmission (but this feature is not always required). It is not necessary for the non-singular code to be more compact than the source (and in many applications, a larger code is useful, for example as a way to detect or recover from encoding or transmission errors, or in security applications to protect a source from undetectable tampering).</li></ul>
<div class="mw-heading mw-heading3"><h3 id="Uniquely_decodable_codes">Uniquely decodable codes</h3></div>
<p>A code is <b>uniquely decodable</b> if its extension is <a href="#Non-singular_codes">§ non-singular</a>. Whether a given code is uniquely decodable can be decided with the <a href="Sardinas%E2%80%93Patterson_algorithm" title="Sardinas–Patterson algorithm">Sardinas–Patterson algorithm</a>.
</p>
<ul><li>The mapping <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{3}=\{\,a\mapsto 0,b\mapsto 01,c\mapsto 011\,\}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>M</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>3</mn>
</mrow>
</msub>
<mo>=</mo>
<mo fence="false" stretchy="false">{</mo>
<mspace width="thinmathspace"></mspace>
<mi>a</mi>
<mo stretchy="false">↦<!-- ↦ --></mo>
<mn>0</mn>
<mo>,</mo>
<mi>b</mi>
<mo stretchy="false">↦<!-- ↦ --></mo>
<mn>01</mn>
<mo>,</mo>
<mi>c</mi>
<mo stretchy="false">↦<!-- ↦ --></mo>
<mn>011</mn>
<mspace width="thinmathspace"></mspace>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle M_{3}=\{\,a\mapsto 0,b\mapsto 01,c\mapsto 011\,\}}</annotation>
</semantics>
</math></span><img src="./d138ebd814abfa230dcebe7f5ce26e5ea764c359.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:32.625ex; height:2.843ex;" alt="{\displaystyle M_{3}=\{\,a\mapsto 0,b\mapsto 01,c\mapsto 011\,\}}" loading="lazy"></span> is uniquely decodable (this can be demonstrated by looking at the <i>follow-set</i> after each target bit string in the map, because each bitstring is terminated as soon as we see a 0 bit which cannot follow any existing code to create a longer valid code in the map, but unambiguously starts a new code).</li>
<li>Consider again the code <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{2}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>M</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle M_{2}}</annotation>
</semantics>
</math></span><img src="./0d5d4dffae5ee0db4cc433e252ee9ed7530e5cf0.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:3.308ex; height:2.509ex;" alt="{\displaystyle M_{2}}" loading="lazy"></span> from the previous section.<sup id="cite_ref-:0_1-1" class="reference"><a href="#cite_note-:0-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> This code is <i>not</i> uniquely decodable, since the string <i>011101110011</i> can be interpreted as the sequence of codewords <i>01110 – 1110 – 011</i>, but also as the sequence of codewords <i>011 – 1 – 011 – 10011</i>. Two possible decodings of this encoded string are thus given by <i>cdb</i> and <i>babe</i>. However, such a code is useful when the set of all possible source symbols is completely known and finite, or when there are restrictions (such as a formal syntax) that determine if source elements of this extension are acceptable. Such restrictions permit the decoding of the original message by checking which of the possible source symbols mapped to the same symbol are valid under those restrictions.</li></ul>
<div class="mw-heading mw-heading3"><h3 id="Prefix_codes">Prefix codes</h3></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Prefix_code" title="Prefix code">Prefix code</a></div>
<p>A code is a <b>prefix code</b> if no target bit string in the mapping is a prefix of the target bit string of a different source symbol in the same mapping. This means that symbols can be decoded instantaneously after their entire codeword is received. Other commonly used names for this concept are <b>prefix-free code</b>, <b>instantaneous code</b>, or <b>context-free code</b>.
</p>
<ul><li>The example mapping <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{3}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>M</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>3</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle M_{3}}</annotation>
</semantics>
</math></span><img src="./eba9967ecd86d57a9d85001e5fe15f93686861d2.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:3.308ex; height:2.509ex;" alt="{\displaystyle M_{3}}" loading="lazy"></span> above is <i>not</i> a prefix code because we do not know after reading the bit string "0" whether it encodes an "a" source symbol, or if it is the prefix of the encodings of the "b" or "c" symbols.</li>
<li>An example of a prefix code is shown below.</li></ul>
<table class="wikitable" style="text-align:center; position: relative; left: 1in;">

<tbody><tr>
<th>Symbol</th>
<th>Codeword
</th></tr>
<tr>
<td>a</td>
<td>0
</td></tr>
<tr>
<td>b</td>
<td>10
</td></tr>
<tr>
<td>c</td>
<td>110
</td></tr>
<tr>
<td>d</td>
<td>111
</td></tr></tbody></table>
<dl><dd><dl><dd>Example of encoding and decoding:
<dl><dd>aabacdab → 00100110111010 → |0|0|10|0|110|111|0|10| → aabacdab</dd></dl></dd></dl></dd></dl>
<p>A special case of prefix codes are <a href="Block_code" title="Block code">block codes</a>. Here, all codewords must have the same length. The latter are not very useful in the context of <a href="Source_coding" class="mw-redirect" title="Source coding">source coding</a>, but often serve as <a href="Forward_error_correction" class="mw-redirect" title="Forward error correction">forward error correction</a> in the context of <a href="Channel_coding" class="mw-redirect" title="Channel coding">channel coding</a>.
</p><p>Another special case of prefix codes are <a href="LEB128" title="LEB128">LEB128</a> and <a href="Variable-length_quantity" title="Variable-length quantity">variable-length quantity</a> (VLQ) codes, which encode arbitrarily large integers as a sequence of octets—i.e., every codeword is a multiple of 8 bits.
</p>
<div class="mw-heading mw-heading2"><h2 id="Advantages">Advantages</h2></div>
<p>The advantage of a variable-length code is that unlikely source symbols can be assigned longer codewords and likely source symbols can be assigned shorter codewords, thus giving a low <a href="Expected_value" title="Expected value"><i>expected</i></a> codeword length. For the above example, if the probabilities of (a, b, c, d) were <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \textstyle \left({\frac {1}{2}},{\frac {1}{4}},{\frac {1}{8}},{\frac {1}{8}}\right)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mstyle displaystyle="false" scriptlevel="0">
<mrow>
<mo>(</mo>
<mrow>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mn>2</mn>
</mfrac>
</mrow>
<mo>,</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mn>4</mn>
</mfrac>
</mrow>
<mo>,</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mn>8</mn>
</mfrac>
</mrow>
<mo>,</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mn>8</mn>
</mfrac>
</mrow>
</mrow>
<mo>)</mo>
</mrow>
</mstyle>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \textstyle \left({\frac {1}{2}},{\frac {1}{4}},{\frac {1}{8}},{\frac {1}{8}}\right)}</annotation>
</semantics>
</math></span><img src="./24e1b077daccbae5602d8206c21680852dafacce.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.838ex; width:12.51ex; height:4.843ex;" alt="{\displaystyle \textstyle \left({\frac {1}{2}},{\frac {1}{4}},{\frac {1}{8}},{\frac {1}{8}}\right)}" loading="lazy"></span>, the expected number of bits used to represent a source symbol using the code above would be:
</p>
<dl><dd><dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 1\times {\frac {1}{2}}+2\times {\frac {1}{4}}+3\times {\frac {1}{8}}+3\times {\frac {1}{8}}={\frac {7}{4}}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>1</mn>
<mo>×<!-- × --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mn>2</mn>
</mfrac>
</mrow>
<mo>+</mo>
<mn>2</mn>
<mo>×<!-- × --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mn>4</mn>
</mfrac>
</mrow>
<mo>+</mo>
<mn>3</mn>
<mo>×<!-- × --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mn>8</mn>
</mfrac>
</mrow>
<mo>+</mo>
<mn>3</mn>
<mo>×<!-- × --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mn>8</mn>
</mfrac>
</mrow>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>7</mn>
<mn>4</mn>
</mfrac>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 1\times {\frac {1}{2}}+2\times {\frac {1}{4}}+3\times {\frac {1}{8}}+3\times {\frac {1}{8}}={\frac {7}{4}}}</annotation>
</semantics>
</math></span><img src="./ed1f2d3d61b4a0f6b31d83cc28bb434222cff2ea.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.838ex; width:37.624ex; height:5.176ex;" alt="{\displaystyle 1\times {\frac {1}{2}}+2\times {\frac {1}{4}}+3\times {\frac {1}{8}}+3\times {\frac {1}{8}}={\frac {7}{4}}}" loading="lazy"></span>.</dd></dl></dd></dl>
<p>As the entropy of this source is 1.75 bits per symbol, this code compresses the source as much as possible so that the source can be recovered with <i>zero</i> error.
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Golomb_code" class="mw-redirect" title="Golomb code">Golomb code</a></li>
<li><a href="Kruskal_count" title="Kruskal count">Kruskal count</a></li>
<li><a href="Variable-length_instruction_set" class="mw-redirect" title="Variable-length instruction set">Variable-length instruction sets</a> in computing</li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */


.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}


/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-:0-1"><span class="mw-cite-backlink">^ <a href="#cite_ref-:0_1-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-:0_1-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text">This code is based on an example found in Berstel et al. (2009), Example 2.3.1, p. 63.</span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="Further_reading">Further reading</h2></div>
<ul><li><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFSalomon2007" class="citation book cs1">Salomon, David (September 2007). <i>Variable-Length Codes for Data Compression</i> (1&nbsp;ed.). <a href="Springer_Verlag" class="mw-redirect" title="Springer Verlag">Springer Verlag</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-1-84628-958-3</bdi>.</cite> (xii+191 pages) <a rel="nofollow" class="external text" href="https://web.archive.org/web/20230920174349/https://www.davidsalomon.name/VLCadvertis/VLCerrata.html">Errata 1</a><a rel="nofollow" class="external text" href="https://web.archive.org/web/20230920175457/https://www.davidsalomon.name/VLCadvertis/phasedin.pdf">Errata 2</a></li>
<li><cite id="CITEREFBerstelPerrinReutenauer2010" class="citation book cs1">Berstel, Jean; Perrin, Dominique; Reutenauer, Christophe (2010). <i>Codes and automata</i>. Encyclopedia of Mathematics and its Applications. Vol.&nbsp;129. Cambridge, UK: <a href="Cambridge_University_Press" title="Cambridge University Press">Cambridge University Press</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-0-521-88831-8</bdi>. <a href="Zbl_(identifier)" class="mw-redirect" title="Zbl (identifier)">Zbl</a>&nbsp;<a rel="nofollow" class="external text" href="https://zbmath.org/?format=complete&amp;q=an:1187.94001">1187.94001</a>.</cite> <a rel="nofollow" class="external text" href="http://www-igm.univ-mlv.fr/~berstel/LivreCodes/Codes.html">Draft available online</a></li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}


/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox" aria-labelledby="Data_compression_methods241" style="padding:3px"><table class="nowraplinks hlist mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div id="Data_compression_methods241" style="font-size:114%;margin:0 4em"><a href="Data_compression" title="Data compression">Data compression</a> methods</div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Lossless_compression" title="Lossless compression">Lossless</a><br>type</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Entropy_coding" title="Entropy coding">Entropy</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Adaptive_coding" title="Adaptive coding">Adaptive coding</a></li>
<li><a href="Arithmetic_coding" title="Arithmetic coding">Arithmetic</a></li>
<li><a href="Asymmetric_numeral_systems" title="Asymmetric numeral systems">Asymmetric numeral systems</a></li>
<li><a href="Golomb_coding" title="Golomb coding">Golomb</a></li>
<li><a href="Huffman_coding" title="Huffman coding">Huffman</a>
<ul><li><a href="Adaptive_Huffman_coding" title="Adaptive Huffman coding">Adaptive</a></li>
<li><a href="Canonical_Huffman_code" title="Canonical Huffman code">Canonical</a></li>
<li><a href="Modified_Huffman_coding" title="Modified Huffman coding">Modified</a></li></ul></li>
<li><a href="Range_coding" title="Range coding">Range</a></li>
<li><a href="Shannon_coding" title="Shannon coding">Shannon</a></li>
<li><a href="Shannon%E2%80%93Fano_coding" title="Shannon–Fano coding">Shannon–Fano</a></li>
<li><a href="Shannon%E2%80%93Fano%E2%80%93Elias_coding" title="Shannon–Fano–Elias coding">Shannon–Fano–Elias</a></li>
<li><a href="Tunstall_coding" title="Tunstall coding">Tunstall</a></li>
<li><a href="Unary_coding" title="Unary coding">Unary</a></li>
<li><a href="Universal_code_(data_compression)" title="Universal code (data compression)">Universal</a>
<ul><li><a href="Exponential-Golomb_coding" title="Exponential-Golomb coding">Exp-Golomb</a></li>
<li><a href="Fibonacci_coding" title="Fibonacci coding">Fibonacci</a></li>
<li><a href="Elias_gamma_coding" title="Elias gamma coding">Gamma</a></li>
<li><a href="Levenshtein_coding" title="Levenshtein coding">Levenshtein</a></li></ul></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Dictionary_coder" title="Dictionary coder">Dictionary</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Byte-pair_encoding" title="Byte-pair encoding">Byte-pair encoding</a></li>
<li><a href="LZ77_and_LZ78" title="LZ77 and LZ78">Lempel–Ziv</a>
<ul><li><a href="842_(compression_algorithm)" title="842 (compression algorithm)">842</a></li>
<li><a href="LZ4_(compression_algorithm)" title="LZ4 (compression algorithm)">LZ4</a></li>
<li><a href="LZJB" class="mw-redirect" title="LZJB">LZJB</a></li>
<li><a href="Lempel%E2%80%93Ziv%E2%80%93Oberhumer" title="Lempel–Ziv–Oberhumer">LZO</a></li>
<li><a href="LZRW" title="LZRW">LZRW</a></li>
<li><a href="Lempel%E2%80%93Ziv%E2%80%93Storer%E2%80%93Szymanski" title="Lempel–Ziv–Storer–Szymanski">LZSS</a></li>
<li><a href="Lempel%E2%80%93Ziv%E2%80%93Welch" title="Lempel–Ziv–Welch">LZW</a></li>
<li><a href="LZWL" title="LZWL">LZWL</a></li>
<li><a href="Snappy_(compression)" title="Snappy (compression)">Snappy</a></li></ul></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Burrows%E2%80%93Wheeler_transform" title="Burrows–Wheeler transform">BWT</a></li>
<li><a href="Context_tree_weighting" title="Context tree weighting">CTW</a></li>
<li><a href="Context_mixing" title="Context mixing">CM</a></li>
<li><a href="Delta_encoding" title="Delta encoding">Delta</a>
<ul><li><a href="Incremental_encoding" title="Incremental encoding">Incremental</a></li></ul></li>
<li><a href="Dynamic_Markov_compression" title="Dynamic Markov compression">DMC</a></li>
<li><a href="Differential_pulse-code_modulation" title="Differential pulse-code modulation">DPCM</a></li>
<li><a href="Grammar-based_code" title="Grammar-based code">Grammar</a>
<ul><li><a href="Re-Pair" title="Re-Pair">Re-Pair</a></li>
<li><a href="Sequitur_algorithm" title="Sequitur algorithm">Sequitur</a></li></ul></li>
<li><a href="Discrete_cosine_transform" title="Discrete cosine transform">LDCT</a></li>
<li><a href="Move-to-front_transform" title="Move-to-front transform">MTF</a></li>
<li><a href="PAQ" title="PAQ">PAQ</a></li>
<li><a href="Prediction_by_partial_matching" title="Prediction by partial matching">PPM</a></li>
<li><a href="Run-length_encoding" title="Run-length encoding">RLE</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Hybrid</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li>LZ77 + Huffman
<ul><li><a href="Deflate" title="Deflate">Deflate</a></li>
<li><a href="LZX" title="LZX">LZX</a></li>
<li><a href="Lempel%E2%80%93Ziv%E2%80%93Stac" title="Lempel–Ziv–Stac">LZS</a></li></ul></li>
<li>LZ77 + ANS
<ul><li><a href="LZFSE" title="LZFSE">LZFSE</a></li></ul></li>
<li>LZ77 + Huffman + ANS
<ul><li><a href="Zstd" title="Zstd">Zstandard</a></li></ul></li>
<li>LZ77 + Huffman + context
<ul><li><a href="Brotli" title="Brotli">Brotli</a></li></ul></li>
<li>LZSS + Huffman
<ul><li><a href="LHA_(file_format)" title="LHA (file format)">LHA/LZH</a></li></ul></li>
<li>LZ77 + Range
<ul><li><a href="LZMA" title="LZMA">LZMA</a></li>
<li>LZHAM</li></ul></li>
<li>RLE + BWT + MTF + Huffman
<ul><li><a href="Bzip2" title="Bzip2">bzip2</a></li></ul></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Lossy_compression" title="Lossy compression">Lossy</a><br>type</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Transform_coding" title="Transform coding">Transform</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Discrete_cosine_transform" title="Discrete cosine transform">Discrete cosine transform</a>
<ul><li><a href="Discrete_cosine_transform" title="Discrete cosine transform">DCT</a></li>
<li><a href="Modified_discrete_cosine_transform" title="Modified discrete cosine transform">MDCT</a></li></ul></li>
<li><a href="Discrete_sine_transform" title="Discrete sine transform">DST</a></li>
<li><a href="Fast_Fourier_transform" title="Fast Fourier transform">FFT</a></li>
<li><a href="Wavelet_transform" title="Wavelet transform">Wavelet</a>
<ul><li><a href="Daubechies_wavelet" title="Daubechies wavelet">Daubechies</a></li>
<li><a href="Discrete_wavelet_transform" title="Discrete wavelet transform">DWT</a></li>
<li><a href="Set_partitioning_in_hierarchical_trees" title="Set partitioning in hierarchical trees">SPIHT</a></li></ul></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Predictive</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Differential_pulse-code_modulation" title="Differential pulse-code modulation">DPCM</a>
<ul><li><a href="Adaptive_differential_pulse-code_modulation" title="Adaptive differential pulse-code modulation">ADPCM</a></li></ul></li>
<li><a href="Linear_predictive_coding" title="Linear predictive coding">LPC</a>
<ul><li><a href="Algebraic_code-excited_linear_prediction" title="Algebraic code-excited linear prediction">ACELP</a></li>
<li><a href="Code-excited_linear_prediction" title="Code-excited linear prediction">CELP</a></li>
<li><a href="Log_area_ratio" title="Log area ratio">LAR</a></li>
<li><a href="Line_spectral_pairs" title="Line spectral pairs">LSP</a></li>
<li><a href="Warped_linear_predictive_coding" title="Warped linear predictive coding">WLPC</a></li></ul></li>
<li>Motion
<ul><li><a href="Motion_compensation" title="Motion compensation">Compensation</a></li>
<li><a href="Motion_estimation" title="Motion estimation">Estimation</a></li>
<li><a href="Motion_vector" class="mw-redirect" title="Motion vector">Vector</a></li></ul></li>
<li><a href="Psychoacoustics" title="Psychoacoustics">Psychoacoustic</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Data_compression#Audio" title="Data compression">Audio</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%">Concepts</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Bit_rate" title="Bit rate">Bit rate</a>
<ul><li><a href="Average_bitrate" title="Average bitrate">ABR</a></li>
<li><a href="Constant_bitrate" title="Constant bitrate">CBR</a></li>
<li><a href="Variable_bitrate" title="Variable bitrate">VBR</a></li></ul></li>
<li><a href="Companding" title="Companding">Companding</a></li>
<li><a href="Convolution" title="Convolution">Convolution</a></li>
<li><a href="Dynamic_range" title="Dynamic range">Dynamic range</a></li>
<li><a href="Latency_(audio)" title="Latency (audio)">Latency</a></li>
<li><a href="Nyquist%E2%80%93Shannon_sampling_theorem" title="Nyquist–Shannon sampling theorem">Nyquist–Shannon theorem</a></li>
<li><a href="Sampling_(signal_processing)" title="Sampling (signal processing)">Sampling</a></li>
<li><a href="Silence_compression" title="Silence compression">Silence compression</a></li>
<li><a href="Sound_quality" title="Sound quality">Sound quality</a></li>
<li><a href="Speech_coding" title="Speech coding">Speech coding</a></li>
<li><a href="Sub-band_coding" title="Sub-band coding">Sub-band coding</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Audio_codec" title="Audio codec">Codec</a><br>parts</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="A-law_algorithm" title="A-law algorithm">A-law</a></li>
<li><a href="%CE%9C-law_algorithm" title="Μ-law algorithm">μ-law</a></li>
<li><a href="Differential_pulse-code_modulation" title="Differential pulse-code modulation">DPCM</a>
<ul><li><a href="Adaptive_differential_pulse-code_modulation" title="Adaptive differential pulse-code modulation">ADPCM</a></li>
<li><a href="Delta_modulation" title="Delta modulation">DM</a></li></ul></li>
<li><a href="Fourier_transform" title="Fourier transform">FT</a>
<ul><li><a href="Fast_Fourier_transform" title="Fast Fourier transform">FFT</a></li></ul></li>
<li><a href="Linear_predictive_coding" title="Linear predictive coding">LPC</a>
<ul><li><a href="Algebraic_code-excited_linear_prediction" title="Algebraic code-excited linear prediction">ACELP</a></li>
<li><a href="Code-excited_linear_prediction" title="Code-excited linear prediction">CELP</a></li>
<li><a href="Log_area_ratio" title="Log area ratio">LAR</a></li>
<li><a href="Line_spectral_pairs" title="Line spectral pairs">LSP</a></li>
<li><a href="Warped_linear_predictive_coding" title="Warped linear predictive coding">WLPC</a></li></ul></li>
<li><a href="Modified_discrete_cosine_transform" title="Modified discrete cosine transform">MDCT</a></li>
<li><a href="Psychoacoustics" title="Psychoacoustics">Psychoacoustic model</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Image_compression" title="Image compression">Image</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%">Concepts</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Chroma_subsampling" title="Chroma subsampling">Chroma subsampling</a></li>
<li><a href="Coding_tree_unit" title="Coding tree unit">Coding tree unit</a></li>
<li><a href="Color_space" title="Color space">Color space</a></li>
<li><a href="Compression_artifact" title="Compression artifact">Compression artifact</a></li>
<li><a href="Image_resolution" title="Image resolution">Image resolution</a></li>
<li><a href="Macroblock" title="Macroblock">Macroblock</a></li>
<li><a href="Pixel" title="Pixel">Pixel</a></li>
<li><a href="Peak_signal-to-noise_ratio" title="Peak signal-to-noise ratio">PSNR</a></li>
<li><a href="Quantization_(image_processing)" title="Quantization (image processing)">Quantization</a></li>
<li><a href="Standard_test_image" title="Standard test image">Standard test image</a></li>
<li><a href="Texture_compression" title="Texture compression">Texture compression</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Methods</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Chain_code" title="Chain code">Chain code</a></li>
<li><a href="Discrete_cosine_transform" title="Discrete cosine transform">DCT</a></li>
<li><a href="Deflate" title="Deflate">Deflate</a></li>
<li><a href="Fractal_compression" title="Fractal compression">Fractal</a></li>
<li><a href="Karhunen%E2%80%93Lo%C3%A8ve_theorem" class="mw-redirect" title="Karhunen–Loève theorem">KLT</a></li>
<li><a href="Pyramid_(image_processing)" title="Pyramid (image processing)">LP</a></li>
<li><a href="Run-length_encoding" title="Run-length encoding">RLE</a></li>
<li><a href="Wavelet_transform" title="Wavelet transform">Wavelet</a>
<ul><li><a href="Daubechies_wavelet" title="Daubechies wavelet">Daubechies</a></li>
<li><a href="Discrete_wavelet_transform" title="Discrete wavelet transform">DWT</a></li>
<li><a href="Embedded_zerotrees_of_wavelet_transforms" title="Embedded zerotrees of wavelet transforms">EZW</a></li>
<li><a href="Set_partitioning_in_hierarchical_trees" title="Set partitioning in hierarchical trees">SPIHT</a></li></ul></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Data_compression#Video" title="Data compression">Video</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%">Concepts</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Bit_rate" title="Bit rate">Bit rate</a>
<ul><li><a href="Average_bitrate" title="Average bitrate">ABR</a></li>
<li><a href="Constant_bitrate" title="Constant bitrate">CBR</a></li>
<li><a href="Variable_bitrate" title="Variable bitrate">VBR</a></li></ul></li>
<li><a href="Display_resolution" title="Display resolution">Display resolution</a></li>
<li><a href="Film_frame" title="Film frame">Frame</a></li>
<li><a href="Frame_rate" title="Frame rate">Frame rate</a></li>
<li><a href="Video_compression_picture_types" title="Video compression picture types">Frame types</a></li>
<li><a href="Interlaced_video" title="Interlaced video">Interlace</a></li>
<li><a href="Video#Characteristics_of_video_streams" title="Video">Video characteristics</a></li>
<li><a href="Video_quality" title="Video quality">Video quality</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Video_codec" title="Video codec">Codec</a><br>parts</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Discrete_cosine_transform" title="Discrete cosine transform">DCT</a></li>
<li><a href="Differential_pulse-code_modulation" title="Differential pulse-code modulation">DPCM</a></li>
<li><a href="Deblocking_filter" title="Deblocking filter">Deblocking filter</a></li>
<li><a href="Lapped_transform" title="Lapped transform">Lapped transform</a></li>
<li>Motion
<ul><li><a href="Motion_compensation" title="Motion compensation">Compensation</a></li>
<li><a href="Motion_estimation" title="Motion estimation">Estimation</a></li>
<li><a href="Motion_vector" class="mw-redirect" title="Motion vector">Vector</a></li></ul></li>
<li><a href="Wavelet_transform" title="Wavelet transform">Wavelet</a>
<ul><li><a href="Daubechies_wavelet" title="Daubechies wavelet">Daubechies</a></li>
<li><a href="Discrete_wavelet_transform" title="Discrete wavelet transform">DWT</a></li></ul></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Information_theory" title="Information theory">Theory</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Compressed_data_structure" title="Compressed data structure">Compressed data structures</a>
<ul><li><a href="Compressed_suffix_array" title="Compressed suffix array">Compressed suffix array</a></li>
<li><a href="FM-index" title="FM-index">FM-index</a></li></ul></li>
<li><a href="Entropy_(information_theory)" title="Entropy (information theory)">Entropy</a></li>
<li><a href="Information_theory" title="Information theory">Information theory</a>
<ul><li><a href="Timeline_of_information_theory" title="Timeline of information theory">Timeline</a></li></ul></li>
<li><a href="Kolmogorov_complexity" title="Kolmogorov complexity">Kolmogorov complexity</a></li>
<li><a href="Prefix_code" title="Prefix code">Prefix code</a></li>
<li><a href="Quantization_(signal_processing)" title="Quantization (signal processing)">Quantization</a></li>
<li><a href="Rate%E2%80%93distortion_theory" title="Rate–distortion theory">Rate–distortion</a></li>
<li><a href="Redundancy_(information_theory)" title="Redundancy (information theory)">Redundancy</a></li>
<li><a href="Data_compression_symmetry" title="Data compression symmetry">Symmetry</a></li>
<li><a href="Smallest_grammar_problem" title="Smallest grammar problem">Smallest grammar problem</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Community</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Hutter_Prize" title="Hutter Prize">Hutter Prize</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">People</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Mark_Adler" title="Mark Adler">Mark Adler</a></li>
<li><a href="Phil_Katz" title="Phil Katz">Phil Katz</a></li></ul>
</div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-02-14" href="https://en.wikipedia.org/wiki/?title=Variable-length_code&amp;oldid=1275750297">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>